<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>使用git</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        a{
            color: black;
            text-decoration: none;
            display: inline-block;
        }
        nav{
            width: 100%;
            height: 30px;
            border-bottom: 1px solid red;
        }
        .logo{float: left}
        .list{
            float: left;
        }
        .list li{
            float: left;
            list-style: none;
            position: relative;
        }
        .list a{
            display: inline-block;
            width: 100px;
            height: 30px;
            text-align: center;
            line-height:30px;
        }
        .login{float: right}
        .navlist{
            position: absolute;
            width: 100px;
            padding-bottom: 10px;
            height: auto;
            top:30px;
            left: 0;
            z-index: 1000;
            border: 1px solid black;
            display: none;
        }
        .navlist ul li{
            float: left;
            list-style: none;
        }
        .navlist ul li a{
            display: inline-block;
            width: 100px;
            height: 30px;
            text-align: center;
            line-height:30px;
        }
        .lista{
            background-color: aquamarine;
        }
    </style>
</head>
<body>
<nav>
    <div class="logo">
        <h3>logo</h3>
    </div>
    <ul class="list" id="ul1">
        <li><a href="javascript:;">首页</a></li>
        <li>
            <a href="javascript:;" id="message" class="listas" >信息</a>
            <div class="navlist">
                <ul>
                    <li><a href="javascript:;">音乐</a></li>
                    <li><a href="javascript:;">阅读</a></li>
                    <li><a href="javascript:;">小说</a></li>
                </ul>
            </div>
        </li>
        <li><a href="javascript:;">产品</a></li>
        <li>
            <a href="javascript:;" id="else" class="listas">其他</a>
            <div class="navlist">
                <ul>
                    <li><a href="javascript:;">音乐</a></li>
                    <li><a href="javascript:;">阅读</a></li>
                    <li><a href="javascript:;">小说</a></li>
                </ul>
            </div>
        </li>
        <li>
            <a href="javascript:;" id="kehu" class="listas">客户</a>
            <div class="navlist" id="kehulist">
                <ul>
                    <li><a href="http://www.baidu.com">百度</a></li>
                    <li><a href="http://www.sohu.com/">搜狐</a></li>
                    <li><a href="javascript:;">新浪</a></li>
                </ul>
            </div>
        </li>
    </ul>
    <div class="login">
        <a href="javascript:;">登陆</a>
    </div>
</nav>
<script>
    /*笨办法*/
//    var kehu=document.getElementById("kehu");
//    var kehulist=document.getElementById("kehulist");
//    kehu.onclick=function(){
//        kehulist.style.display="block"
//    };
//    kehulist.onmouseout=function(){
//        kehulist.style.display="none"
//    };

    /*新办法*/
    window.onload = function(){
        var oUl = document.getElementById("ul1");
        oUl.onclick = function(ev){
            var ev = ev || window.event;
            var target = ev.target || ev.srcElement;
            if(target.nodeName.toLowerCase() == 'li'){
                alert(123);
                alert(target.innerHTML);
            }
        }
    }


</script>
</body>
</html>